package org.core.blog.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.core.blog.pojo.Article;
import org.core.blog.pojo.SearchParam;

import java.util.List;

@Mapper
public interface ArticleMapper {

    @Select("select * from article")
    List<Article> findAll();

    @Insert("insert into article(title,content,category_id,user_id,created_at,updated_at) values(#{title},#{content},#{categoryId},#{userId},#{createdAt},#{updatedAt})")
    void InsertArticle(Article article);

    @Select("select * from article where id=#{id}")
    Article selectArticleById(Integer id);

    void updateById(Article article);

    @Delete("delete from article where id=#{id}")
    void deleteById(Integer id);

    List<Article> queryByParam(SearchParam searchParam);
}
